#ifndef SENSOR_H
#define SENSOR_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h> 
#include <pthread.h>
#include <time.h>

#define true  1
#define false 0

#define SIZE     256
#define BSIZE    256
#define FLAGS    0
#define FAILURE -1
#define PORT     8080

struct TDATA {
 int src,dest,type;
 char msg[BSIZE];
};

// Number of threads.
#define NUM_REPOS   1
#define NUM_SENSORS 10
#define NUM_CLIENTS 10
#define NUM_TOTAL   NUM_REPOS+NUM_SENSORS+NUM_CLIENTS

// Thread ID ranges.
#define TBEG        0
#define RBEG        0
#define SBEG        REND
#define CBEG        SEND
#define REND        RBEG+NUM_REPOS
#define SEND        SBEG+NUM_SENSORS
#define CEND        CBEG+NUM_CLIENTS
#define TEND        NUM_TOTAL

// Type of request.
#define PULL 1
#define PUSH 2
#define DATA 3
#define ACK  4


void error(const char *);

#define SOCK_ERROR  error("Error creating socket.")
#define BIND_ERROR  error("Error binding socket.")
#define CONN_ERROR  error("Error connecting.")
#define ACPT_ERROR  error("Error accepting.")
#define SEND_ERROR  error("Error sending.")
#define RECV_ERROR  error("Error receiving.")

#define SPEED_RANGE   20
#define SPEED_MIN     50
#define NUM_ROADS     25

#define NOT_SPEC      -1

#endif
